<?php
require_once("../login/class.session.php");
require_once("../functions.php");

if (!isset($session->logged_in) || !$session->logged_in) {
  header("Location: ../createaccount.php");
}
$userinfo = $session->userinfo;
$userid = $userinfo['id'];

require_once("../facebook-php-sdk/src/facebook.php");

$facebook = new Facebook(array(
  'appId'  => '166511040068674',
  'secret' => '60a50fd29897c6888b560fa21f9414cc',
  'cookie' => true, // enable optional cookie support
));

?>

<?php require_once("../header.php"); ?>
<div class = "box submenu">
  <h3>Update My Profile</h3>
  <ul>
    <li id = "view" class="selected"><img src = "../layout/musical_note.png" />View My Profile</li>
    <li id = "edit" class=""><img src = "../layout/pencil_icon.gif" />Edit My Profile</li>
    <li><img src = "../layout/myspace.png" /><a href="../registerNetwork.php?mode=myspace">MySpace Account</a>
        <?php if (isset($_SESSION['myspaceLoggedIn'])) { echo " - logged in"; } ?> 
	</li>
    <li><img src = "../layout/twitter.png" /><a href="../registerNetwork.php?mode=twitter">Twitter Account</a>
		<?php if (is_integrated_with("twitter", $userid)) { echo " - logged in"; } ?>
	</li>
    <li><img src = "../layout/facebook.png" />
    <?php  
        if ($facebook->getSession()) {
          echo '<a href="' . $facebook->getLogoutUrl() . '">Facebook Account - logged in</a>';
        } else {
          echo '<a href="' . $facebook->getLoginUrl() . '">Facebook Account</a>';
        }
    ?>
	</li>
    <li><img src = "../layout/soundcloud-icon.gif"/><a href="../registerNetwork.php?mode=soundcloud">Soundcloud Account</a>
		<?php if (is_integrated_with("soundcloud", $userid)) { echo " - logged in"; } ?>
	</li>
    <li><img src = "../layout/icon-bandcamp.gif" />BandCamp Account</li>
  </ul>
</div>
<div id = "change" class = "box profile">
<table>		
	<form method="post" action="doprofile.php">
    <h3><span class = "username"><?=$userinfo['username']?></span>'s Profile</h3>

		<tr><td colspan="2"><h4>Contact Information</h4></td></tr>
		<tr>
      <td>Username:</td> <td><?=$userinfo['username'] ?></td>
		</tr>
		<tr>
      <td class = "padding">Display Name:</td><td><?=$userinfo['displayname']?></td>
		</tr>
		<tr>
			<td>Email:</td><td><?=$userinfo['email']?></td>
		</tr>
		<tr>
			<td>Website:</td><td><?=$userinfo['website']?></td>
		</tr>
		<tr>
      <td>Location:</td><td><?
        echo $userinfo['city'];
        if(is_not_null($userinfo['city']) && is_not_null($userinfo['state'])) {
          echo ", "; 
        }
        echo $userinfo['state'];
        if(is_not_null($userinfo['state']) && is_not_null($userinfo['country'])) {
          echo ", "; 
        }
        echo $userinfo['country'];
        ?>
      </td>
		</tr>
    <tr><td colspan="2"><h4>Artist Information</h4></td></tr>
		<tr>
			<td>Members:</td><td><?=$userinfo['members']?></td>
		</tr>
		<tr>
			<td>Genre:</td><td><?=$userinfo['genre']?></td>
		</tr>
		<tr>
			<td>Record Label:</td><td><?=$userinfo['recordlabel']?></td>
		</tr>
		<tr>
			<td>Bio:</td><td><?=$userinfo['bio']?></td>
		</tr>
		<tr>
			<td>Influences:</td><td><?=$userinfo['influences']?></td>
		</tr>
		<tr>
			<td>Sounds Like:</td><td><?=$userinfo['soundslike']?></td>
		</tr>

	</form>
</table>
</div>

<?php require_once("../footer.php");
